<template>
  <div class="past">
    <div class="head">
      <span>年份：</span>
      <el-select v-model="year" filterable placeholder="请选择">
        <el-option
          v-for="item in years"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <span>省份：</span>
      <el-select v-model="sfmc" filterable placeholder="请选择">
        <el-option
          v-for="item in sfmcs"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <button @click="inquiry">查询</button>
    </div>

    <el-table :data="tableData" height="720" border style="width: 100%">
      <el-table-column prop="yxmc" label="院系名称" width="280">
      </el-table-column>
      <el-table-column prop="zymc" label="专业名称" width="280">
      </el-table-column>
      <el-table-column prop="xz" label="学制"> </el-table-column>
      <el-table-column prop="klmc" label="科类" width="280">
      </el-table-column>
      <el-table-column prop="zsrs" label="招生人数" width="240">
      </el-table-column>
      <el-table-column prop="jhlbmc" label="计划类别名称" width="280">
      </el-table-column>
    </el-table>
    
  </div>
</template>

<script>
import { request } from '../../network/request'
export default {
  name: '',
  data() {
    return {
      years: [
        {
          label: '2003',
          value: '2003'
        },
        {
          label: '2004',
          value: '2004'
        },
        {
          label: '2005',
          value: '2005'
        },
        {
          label: '2006',
          value: '2006'
        },
        {
          label: '2007',
          value: '2007'
        },
        {
          label: '2008',
          value: '2008'
        },
        {
          label: '2009',
          value: '2009'
        },
        {
          label: '2010',
          value: '2010'
        },
        {
          label: '2011',
          value: '2011'
        },
        {
          label: '2012',
          value: '2012'
        },
        {
          label: '2013',
          value: '2013'
        },
        {
          label: '2014',
          value: '2014'
        },
        {
          label: '2015',
          value: '2015'
        },
        {
          label: '2016',
          value: '2016'
        },
        {
          label: '2017',
          value: '2017'
        },
        {
          label: '2018',
          value: '2018'
        },
        {
          label: '2019',
          value: '2019'
        },
        {
          label: '2020',
          value: '2020'
        },
      ],
      year: '',
      sfmcs: [
        {
          value: "北京",
          label: "北京",
        },
        {
          value: "天津",
          label: "天津",
        },
        {
          value: "上海",
          label: "上海",
        },
        {
          value: "重庆",
          label: "重庆",
        },
        {
          value: "河北",
          label: "河北",
        },
        {
          value: "山西",
          label: "山西",
        },
        {
          value: "辽宁",
          label: "辽宁",
        },
        {
          value: "吉林",
          label: "吉林",
        },
        {
          value: "黑龙江",
          label: "黑龙江",
        },
        {
          value: "江苏",
          label: "江苏",
        },
        {
          value: "浙江",
          label: "浙江",
        },
        {
          value: "安徽",
          label: "安徽",
        },
        {
          value: "福建",
          label: "福建",
        },
        {
          value: "江西",
          label: "江西",
        },
        {
          value: "山东",
          label: "山东",
        },
        {
          value: "河南",
          label: "河南",
        },
        {
          value: "湖北",
          label: "湖北",
        },
        {
          value: "湖南",
          label: "湖南",
        },
        {
          value: "广东",
          label: "广东",
        },
        {
          value: "海南",
          label: "海南",
        },
        {
          value: "四川",
          label: "四川",
        },
        {
          value: "贵州",
          label: "贵州",
        },
        {
          value: "云南",
          label: "云南",
        },
        {
          value: "陕西",
          label: "陕西",
        },
        {
          value: "甘肃",
          label: "甘肃",
        },
        {
          value: "青海",
          label: "青海",
        },
        {
          value: "台湾",
          label: "台湾",
        },
        {
          value: "内蒙古",
          label: "内蒙古",
        },
        {
          value: "广西",
          label: "广西",
        },
        {
          value: "西藏",
          label: "西藏",
        },
        {
          value: "宁夏",
          label: "宁夏",
        },
        {
          value: "新疆",
          label: "新疆",
        },
        {
          value: "香港",
          label: "香港",
        },
        {
          value: "澳门",
          label: "澳门",
        },
      ],
      sfmc: "",
      tableData: [
      ]
    }
  },
  methods: {
    inquiry(){
      if(this.year == '' || this.sfmc == '') {
        alert("年份与省份不能为空")
      }else {
        request({
        url: 'http://118.31.51.131:8081/api/zsjhs/ck',
        method: 'get',
        params: {
          sfmc: this.sfmc,
          year: this.year
        }
      }).then(value => {
        console.log(value);
        this.tableData = value.data
      }).catch(err => {
        console.log(err);
      })
      }
    }
  },
  // beforeCreate() {
  //   if (sessionStorage.getItem("token") == null) {
  //     this.$router.push("/login");
  //   } else {
  //     let token = sessionStorage.getItem("token");
  //     let length = sessionStorage.getItem("token").length;
  //     if (token[length - 5] == "0") {
  //       this.$router.replace("/function/login");
  //     }
  //   }
  // },
  components: {}
}
</script>

<style scoped>
.head {
  height: 80px;
  border-bottom: 1px solid black;
}
.head span {
  font-size: 20px;
  line-height: 80px;
  margin-left: 25px;
}
.head button {
  margin-left: 860px;
}
.head button {
  width: 100px;
  height: 50px;
  border: none;
  outline: none;
  cursor: pointer;
  color: #fff;
  background-color: rgb(192, 51, 56);
}
button:active {
  opacity: 0.8;
}
.past ::v-deep .el-table .cell {
  text-align: center;
}
</style>